package org.edith.shiro.dao;


import org.apache.ibatis.annotations.*;
import org.edith.shiro.dataobject.SysUserDO;

/**
 * 系统用户DAO
 */
public interface SysUserDAO {
    @Insert("create table  if not exists sys_user\n" +
            "        (\n" +
            "          user_id     bigint auto_increment comment '用户ID' primary key,\n" +
            "          username    varchar(50) not null comment '用户名',\n" +
            "          password    varchar(100)  null comment '密码',\n" +
            "          salt        varchar(50)   null comment '盐值',\n" +
            "          status      varchar(50) null DEFAULT 'NORMAL' comment '状态:NORMAL正常  PROHIBIT禁用',\n" +
            "          create_time datetime default CURRENT_TIMESTAMP null comment '创建时间',\n" +
            "          create_user varchar(256) null comment '创建该账号的操作者',\n" +
            "          modify_time datetime default CURRENT_TIMESTAMP null comment '修改时间',\n" +
            "          modify_user varchar(256) null comment '修改该账户的操作者',\n" +
            "          remark      varchar(256)  null comment '备注信息'\n" +
            "        ) comment '系统用户表' charset = utf8;")
    void createTable();

    @Results(value = {
            @Result(column = "user_id", property = "userId"),
            @Result(column = "username", property = "username"),
            @Result(column = "password", property = "password"),
            @Result(column = "salt", property = "salt"),
            @Result(column = "status", property = "status"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "create_user", property = "createUser"),
            @Result(column = "modify_time", property = "modifyTime"),
            @Result(column = "modify_user", property = "modifyUser"),
            @Result(column = "remark", property = "remark")
    })
    @Select("select * from sys_user where username = #{username}")
    SysUserDO selectUserByName(@Param("username") String username);
}
